package com.xm.xmapp.response.bean;

import java.util.List;

import android.graphics.Bitmap;

import com.amap.api.maps.model.LatLng;
import com.xm.xmapp.MainActivity;
import com.xm.xmapp.R;
import com.xm.xmapp.app.MyAppcation;
import com.xm.xmapp.map.ClusterItem;
import com.xm.xmapp.tools.ImageTool;

public class ResponseAllNetworkCoords {

	public int times;
	public int is_update;
	public List<Point> points;

	public static class Point implements ClusterItem {

		/**
		 * 
		 */
		private static final long serialVersionUID = -982202398810814664L;
		public String network_name, longitude, latitude;
		public int networkId, networkType, handle_long_rent, has_imgs;
		public int cars, longrent_car_number, is_send_car_service, car_total;
		public static final int TYPE_OLD = 0;
		public static final int TYPE_SHORT = 1;
		public static final int TYPE_SHORT_LONG = 2;
		public static final int TYPE_LONG = 3;
		public int network_rent_type;// 网点租赁类型：0=没有字段1=分时，2=分时和长租，3=长租

		/**
		 * 本地定义常量
		 */
		private final int maxCar = 99;

		@Override
		public LatLng getLatLng() {
			LatLng lat = new LatLng(Double.parseDouble(latitude), Double.parseDouble(longitude));
			return lat;
		}

		@Override
		public String getName() {
			return network_name;
		}

		@Override
		public int getNetworkId() {
			return networkId;
		}

		public int getCar_total() {
			return car_total;
		}

		@Override
		public int getCars(int flag) {
			if (flag == MainActivity.FLAG_SHORT_TIME)
				return cars;
			else
				return longrent_car_number;
		}

		@Override
		public Bitmap getImageBitmap(int flag) {
			int car = getCars(flag);
			if (is_send_car_service == 1 && flag == MainActivity.FLAG_SHORT_TIME) {
				if (getCar_total() > maxCar) {
					if (car > maxCar)
						return ImageTool.getNewBitmap(maxCar, maxCar, MyAppcation.getMyAppcation(),
								R.mipmap.net_send_car_bg_1);
					else
						return ImageTool.getNewBitmap(car, maxCar, MyAppcation.getMyAppcation(), R.mipmap.net_send_car_bg_2);
				} else {
					return ImageTool.getNewBitmap(car, getCar_total(), MyAppcation.getMyAppcation(),
							R.mipmap.net_send_car_bg_4);
				}
			} else {
				if (getCar_total() > maxCar) {
					if (car > maxCar)
						return ImageTool.getNewBitmap(maxCar, maxCar, MyAppcation.getMyAppcation(),
								R.mipmap.net_img_bg_1);
					else
						return ImageTool.getNewBitmap(car, maxCar, MyAppcation.getMyAppcation(), R.mipmap.net_send_car_bg_2);
				} else {
					return ImageTool.getNewBitmap(car, getCar_total(), MyAppcation.getMyAppcation(),
							R.mipmap.net_img_bg_4);
				}
			}
		}

		@Override
		public int getIs_send_car_service() {
			return is_send_car_service;
		}

		@Override
		public int getType() {
			return ClusterItem.TYPE_NETWORK;
		}

		@Override
		public boolean hasImgs() {
			if (has_imgs == 0)
				return false;
			else
				return true;
		}
	}
}
